﻿@using System.Linq
@using CoralNode.Core.Entity.Enums
@using CoralNode.MvcClient.Helper
@using CoralNode.MvcClient.Models;
@using CoralNode.MvcClient.Contexts;
@{
    ViewBag.Title = "主页";
    IList<StatisticModel> statisticList = ViewBag.StatisticList;
    ComponentHelper ch=new ComponentHelper();
    ch.TreeComments(8);
}
<div class="pbody_style2 pb_2" id="pbody">
    <div class="extra">
        @if (CoralNodeContext.Current.Workbench.Id == CoralNodeContext.Current.ManageSite.Id)
        { 
            <div class="index_cnt f_l">
                <div class="top">快速管理 </div>
                <div class="cnt clearfix">
                    <div class="info w_18-5">
                        <span class="ico ico_manageinfo_site mt_2 mb_3"></span>
                        <p>
                            网站<a href="/m/site/" class="btn btn_2">@ViewBag.AllSiteList.Count</a>个<br />
                            启用 <i class="num">@ViewBag.RunSiteList.Count</i> 个，禁用<i class="num">@ViewBag.InVaildSiteCount</i>个
                        </p>
                    </div>
                    <i class="vr"></i>
                    <div class="info w_18-5">
                        <span class="ico ico_manageinfo_file mt_2 mb_3"></span>
                        <p>
                            文件<a href="/m/file/" class="btn btn_2">@ViewBag.AllFileNum</a>个<br />
                            图片 <i class="num">@ViewBag.ImageFileNum</i> 个，文档<i class="num">@ViewBag.DocFileNum</i>个，
                            视频<i class="num">@ViewBag.VideoFileNum</i>个,音频<i class="num">@ViewBag.AudioFileNum</i>个
                        </p>
                    </div>
                    <i class="vr"></i>
                    <div class="info w_18-5">
                        <span class="ico ico_manageinfo_user mt_2 mb_3"></span>
                        <p>
                            用户<a href="/m/user/" class="btn btn_2">@ViewBag.AllUserNum</a>个<br />
                            @{
            int num = 0;
                            }
                            @foreach (var item in (Dictionary<string, int>)ViewBag.UserRoleNumList)
                            {
                                num += item.Value;
                                <span>@item.Key <i class="num">@item.Value</i> 个   </span>
                                <br />
                            }
                            <span>其他用户<i class="num">@(@ViewBag.AllUserNum - num)</i> 个   </span>
                        </p>
                    </div>
                    <i class="vr"></i>
                    <div class="list_manage clearfix f_r w_26-5 mr_1-5" data-js="index_manage">
                        <ul>
                            @if (CoralNodeContext.Current.ManageSite.Id == CoralNodeContext.Current.Workbench.Id)
                            {
                                <li><a href="/m/quickSetting"><span class="ico ico_setting_setting_grey"></span>快速建站向导</a>
                                </li>
                                <li><a href="/m/site"><span class="ico ico_setting_site_grey"></span>网站管理</a></li>
                                <li><a href="/m/user"><span class="ico ico_setting_user_grey"></span>用户管理</a></li>
                                <li><a href="/m/site/listTheme"><span class="ico ico_setting_file_grey"></span>主题管理</a>
                                </li>
                                <li><a href="/m/site/editSite/@ViewBag.WorkbenchContext.Id"><span class="ico ico_setting_system_grey"></span>系统设置</a></li>
                                <li><a href="/m/statistic"><span class="ico ico_setting_visit_grey"></span>统计访问</a>
                                </li>
                            }
                            else
                            { 
                                <li><a href="/m/site"><span class="ico ico_setting_setting_grey"></span>内容管理</a>
                                </li>
                                <li><a href="/m/file"><span class="ico ico_setting_file_grey"></span>文件管理</a></li>
                                <li><a href="/m/menu"><span class="ico ico_setting_site_grey"></span>菜单设计</a></li>
                                <li><a href="/m/prototype"><span class="ico ico_setting_user_grey"></span>内容设计</a>
                                </li>
                                <li><a href="/m/site/editSite/@ViewBag.WorkbenchContext.Id"><span class="ico ico_setting_system_grey"></span>网站设置</a></li>
                                <li><a href="/m/statistic"><span class="ico ico_setting_visit_grey"></span>统计访问</a>
                                </li>
                            }
                        </ul>
                    </div>
                </div>
            </div>
        }
        @foreach (var item in ViewBag.RunSiteList)
        {
            <div class="index_cnt f_l">
                <div class="top">@item.Name</div>
                <div class="cnt">
                    @{
            var statistic = @statisticList.Where(n => n.SiteId == item.Id).FirstOrDefault();
                    }
                    <div style="width: 260px; height: 260px;" class="cnt_main mt_2 f_l ml_2 js_chartContainer">
                        <textarea class="js_categories" style="display: none">@statistic.Categories</textarea>
                        <textarea class="js_series" style="display: none">@statistic.Series</textarea>
                    </div>
                    <div class=" list_sentence w_30 pl_4">
                        <div class="t pl_1">最多访问</div>
                        <div class="cnt pl_1">
                            <ul>
                                @foreach (var p in ManageHtmlHelper.GetNodePvList(item.Id,8))
                                {
                                    <li><a href="/m/node/editNode/@p.Id">@p.Title</a></li>
                                }
                            </ul>
                        </div>
                    </div>
                    <div class="list_sentence w_30 pl_2">
                        <div class="t pl_1">最近添加</div>
                        <div class="cnt pl_1">
                            <ul>
                                @foreach (var node in item.NodeList)
                                {
                                    <li><a href="/m/node/editNode/@node.Id">@node.Title</a></li>
                                }
                            </ul>
                        </div>
                    </div>


                </div>
            </div>
        }
    </div>
</div>
<script src="/Themes/CoralAdmin/_misc/scripts/Highcharts/js/highcharts.src.js"></script>
<script type="text/javascript">
    $(function () {
        $('.js_chartContainer').each(function () {
            var $this = $(this),
            categories = $this.find(".js_categories").val(),
            series = $this.find(".js_series").val();
            $this.highcharts({
                title: {
                    text: ''
                },
                credits: {
                    enabled: false
                },
                xAxis: {
                    categories: categories.split(",")
                },
                yAxis: {
                    title: { text: "" }
                },
                tooltip: {

                },
                legend: {
                    borderWidth: 0
                },
                series: eval("[" + series + "]")
            });
        })

    });
</script>
